package com.example.day04;

/**
 * @author Lenovo
 */
public class Demo9 {
        public static void main(String[] args) {
            int[] numbers = {5, 3, 9, 1, 6, -2};

            // 检查数组是否为空
            if (numbers.length == 0) {
                System.out.println("数组为空！");
                return;
            }

            int min = numbers; // 初始化为第一个元素

            // 遍历数组比较元素
            for (int i = 1; i < numbers.length; i++) {
                if (numbers[i] < min) {
                    min = numbers[i];
                }
            }

            System.out.println("数组最小值: " + min); // 输出: -2
        }
    }
    }
